#include "stdafx.h"
#include "CCommonPlatformServices.h"
#include "CommonResourceProvider.h"

CCommonPlatformServices::CCommonPlatformServices()
{
	this->m_pCustomControlHostExists = FALSE;
	this->m_pCanLoadAssembliesDomainNeutral = TRUE;
}

HRESULT CCommonPlatformServices::GetApplicationID( struct IPALUri * pXapUri, XBOOL bRegister, CXString * * ppstrAppID )
{
	*ppstrAppID = NULL;
	return 0x80004005u;
}

HRESULT CCommonPlatformServices::UnregisterApplicationID( CXString * pstrAppID )
{
	throw std::logic_error("The method or operation is not implemented.");
}

void CCommonPlatformServices::SetCanLoadAssembliesDomainNeutral( XBOOL pValue )
{
	XINT32 pIntValue = this->m_pCanLoadAssembliesDomainNeutral;
	this->InterlockedCompareExchange(&this->m_pCanLoadAssembliesDomainNeutral,pIntValue && pValue,pIntValue);
}

XBOOL CCommonPlatformServices::CanLoadAssembliesDomainNeutral()
{
	return this->InterlockedCompareExchange(&this->m_pCanLoadAssembliesDomainNeutral,-1,-1);
}

void CCommonPlatformServices::SetCustomControlHostExists( XBOOL pValue )
{
	throw std::logic_error("The method or operation is not implemented.");
}

XBOOL CCommonPlatformServices::CustomControlHostExists()
{
	throw std::logic_error("The method or operation is not implemented.");
}

HRESULT CCommonPlatformServices::CreateResourceProvider( struct IPALResourceProvider * * ppResourceProvider )
{
	CommonResourceProvider *pResourceProvider = NULL;

	HRESULT hr = CommonResourceProvider::Create(&pResourceProvider);
	if ( SUCCEEDED(hr) )
	{
		*ppResourceProvider = pResourceProvider;
		pResourceProvider = NULL;
	}
	else
	{

	}
	if ( pResourceProvider )
	{
		pResourceProvider->Release();
		pResourceProvider = NULL;
	}
	return hr;
}

HRESULT CCommonPlatformServices::GetOfflineApplicationStoreDirectory( XUINT32, struct IPALDirectory * * )
{
	throw std::logic_error("The method or operation is not implemented.");
}

HRESULT CCommonPlatformServices::GetAppIdIndexDirectory( XUINT32, struct IPALDirectory * * )
{
	throw std::logic_error("The method or operation is not implemented.");
}
